import random

def bubble(lst):
    n = len(lst)
    for d in range(n//2):
        for i in range(d,n-d-1):
            if lst[i] > lst[i+1] :
                lst[i],lst[1+i]=lst[i+1],lst[i]
        for i in range(n-d-1,d,-1):
            if lst[i] < lst[i-1] :
                lst[i],lst[i-1]=lst[i-1],lst[i]
    return lst

if __name__ == "__main__":
    n = 10000
    lst = list({random.randrange(n,10*n-1) for i in range(n)})
    print(bubble(lst)==sorted(lst))
    # print(lst)